var Fight,
  __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })();
!(function (t) {
  var e = Laya.List,
    i = Laya.Image,
    o = Laya.Dialog,
    s = Laya.Handler,
    l = (function () {
      function t(t, e) {
        (this.bg = "comp/commonpic/bg_dialog_item.png"),
          (this.skin = "comp/commonpic/bg_dialog_6.png"),
          (this.inited = !1),
          (this.p = t),
          this.bind();
      }
      return (
        (t.prototype.init = function () {
          (UIConfig.closeDialogOnSide = !0),
            (this.dialog = new o()),
            (this.dialog.zOrder = 2e4),
            this.dialog.size(t.WID, t.HEI),
            (this.dialog.closeHandler = Laya.Handler.create(
              this,
              this.closeFn,
              null,
              !1
            ));
          var l = new i(this.bg);
          l.size(t.WID, t.HEI),
            (l.top = 20),
            (l.right = 10),
            (l.bottom = 10),
            (l.left = 10),
            (l.sizeGrid = "67,166,68,78"),
            this.dialog.addChild(l);
          var n = new a();
          (n.bgColor = "#E9CB9F"),
            (n.fontSize = 16),
            (n.color = "#ff6c00"),
            (n.bold = !0),
            (n.align = "center"),
            (n.valign = "middle"),
            (n.width = 92),
            (n.height = 28),
            n.pos((t.WID - 92) / 2, 4),
            (this.titleLabel = n),
            this.dialog.addChild(n),
            (l = new i(this.skin)).size(t.WID, t.HEI),
            (l.sizeGrid = "50,70,31,70"),
            this.dialog.addChild(l);
          var d = new e();
          (d.itemRender = r),
            (d.repeatX = 1),
            (d.repeatY = 10),
            d.size(180, 240),
            d.pos(20, 40),
            (d.vScrollBarSkin = ""),
            (d.selectEnable = !0),
            (d.selectHandler = new s(this, this.onSelect)),
            (d.renderHandler = new s(this, this.updateItem)),
            (this.goodsList = d),
            this.dialog.addChild(d),
            (this.inited = !0);
        }),
        (t.prototype.bind = function () {
          WebSocketService.addListener(
            { caller: this, code: 700, method: this.receiveGoods },
            !0
          ),
            WebSocketService.addListener(
              { caller: this, code: 705, method: this.receiveCortege },
              !0
            );
        }),
        (t.prototype.open = function (t) {
          (this.type = t),
            this.inited ? (this.goodsList.selectedIndex = -1) : this.init(),
            "goods" == t &&
              ((this.titleLabel.text = "选择物品"),
              (this.goodsList.array = []),
              WebSocketService.send({ c: 700, d: { pageNum: 0 } })),
            "skill" == t && (this.titleLabel.text = "选择技能"),
            "summon" == t &&
              ((this.titleLabel.text = "选择副将"),
              (this.goodsList.array = []),
              WebSocketService.send({ c: 705, d: {} })),
            this.dialog.popup(!0);
        }),
        (t.prototype.updateItem = function (t, e) {
          "goods" == this.type && t.setGoods(t.dataSource),
            "skill" == this.type && t.setSkill(t.dataSource),
            "summon" == this.type && t.setCortege(t.dataSource);
        }),
        (t.prototype.onSelect = function (t) {
          if (!(t < 0)) {
            var e = this.p,
              i = this.goodsList.selectedItem;
            "goods" == this.type && e.selectGoods(i.id, i.name),
              "skill" == this.type && e.selectKill(i.id, i.name),
              "summon" == this.type && e.selectCortege(i.id, i.name),
              this.dialog.close();
          }
        }),
        (t.prototype.receiveGoods = function (t) {
          null != t.list &&
            0 != t.list.length &&
            (this.goodsList.array = t.list);
        }),
        (t.prototype.receiveCortege = function (t) {
          null != t.list &&
            0 != t.list.length &&
            (this.goodsList.array = t.list);
        }),
        (t.prototype.setKillList = function (t) {
          this.goodsList.array = t;
        }),
        (t.prototype.closeFn = function (t) {
          "side" == t && this.p.buttionClick("attack");
        }),
        (t.prototype.closeDialog = function () {
          this.dialog && this.dialog.close();
        }),
        (t.WID = 220),
        (t.HEI = 300),
        t
      );
    })();
  t.FightGoods = l;
  var n = Laya.Box,
    a = Laya.Label,
    r = (function (t) {
      function e() {
        var i = t.call(this) || this,
          o = new a();
        return (
          o.size(e.WID, e.HEI),
          (o.fontSize = 15),
          (o.color = "#232628"),
          (o.valign = "middle"),
          (i.label = o),
          i.addChild(o),
          i
        );
      }
      return (
        __extends(e, t),
        (e.prototype.setSkill = function (t) {
          (this.label.text = t.name),
            (this.label.color = "#232628"),
            (this.label.align = "center"),
            (this.label.fontSize = 16);
        }),
        (e.prototype.setCortege = function (t) {
          (this.label.text = t.name + "(" + t.lvl + "级)"),
            (this.label.color = "#232628"),
            (this.label.align = "center"),
            (this.label.fontSize = 16);
        }),
        (e.prototype.setGoods = function (t) {
          var e = t.name + "(" + t.num + ")  ",
            i = this.label.color;
          t.num < 10 && (e += "  "),
            t.add_hp > 0 && ((e = e + "+" + t.add_hp + "HP"), (i = "#ff0000")),
            t.add_mp > 0 && ((e = e + "+" + t.add_mp + "MP"), (i = "#0000ff")),
            t.add_hp_rate > 0 &&
              ((e = e + "+" + t.add_hp_rate + "%HP"), (i = "#ff0000")),
            t.add_mp_rate > 0 &&
              ((e = e + "+" + t.add_mp_rate + "%MP"), (i = "#0000ff")),
            (this.label.text = e),
            (this.label.color = i),
            (this.label.align = "left"),
            (this.label.fontSize = 15);
        }),
        (e.WID = 180),
        (e.HEI = 24),
        e
      );
    })(n);
})(Fight || (Fight = {}));
